//
//  CXBaseModel.m
//  ChangZhouInHand
//
//  Created by dllo on 15/10/21.
//  Copyright © 2015年 巢鑫. All rights reserved.
//

#import "CXBaseModel.h"

@implementation CXBaseModel

#pragma mark - 初始化
- (instancetype)initWithDic:(NSDictionary *)dic {
    if ([super init]) {
        // 给对象自己赋值
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

#pragma mark - 便利构造器
+ (instancetype)modelWithDic:(NSDictionary *)dic {
    id m = [[[self class] alloc] initWithDic:dic];
    return m ;
}

#pragma mark - KVC赋值容错
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

#pragma mark - 数组转化
+ (NSMutableArray *)transformWithArray:(NSArray *)array {
    NSMutableArray *arr = [NSMutableArray array];
    for (NSDictionary *dic in array) {
        @autoreleasepool {
            id t = [self modelWithDic:dic];
            [arr addObject:t];
        }
    }
    return arr;
}


@end
